package com.tianhui.consignortwofei.mvp.ui.viewHolder.detail;

import android.text.Html;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.tianhui.consignortwofei.R;
import com.tianhui.consignortwofei.mvp.model.enty.detailItem.DetailRemarkInfo;

import org.yczbj.ycrefreshviewlib.holder.BaseViewHolder;

/**
 * @author fgs
 * @date 2020/8/28
 * @description
 **/
public class DetailRemarkViewHolder extends BaseViewHolder<DetailRemarkInfo> {
    private LinearLayout topLinearLayout;
    private View topLineView;
    private TextView topLeftTextView;
    private TextView topRightTextView;
    private TextView titleTextView;
    private View titleTipView;
    private TextView remarkTextView;

    public DetailRemarkViewHolder(ViewGroup parent, int res) {

        super(parent, res);
        topLinearLayout = getView(R.id.item_detail_remark_topLinearLayout);
        topLineView = getView(R.id.item_detail_remark_topLineView);
        topLeftTextView = getView(R.id.item_detail_remark_topLeftTextView);
        topRightTextView = getView(R.id.item_detail_remark_topRightTextView);
        titleTextView = getView(R.id.layout_item_detail_title_titleTextView);
        titleTipView = getView(R.id.layout_item_detail_title_titleTipView);
        remarkTextView = getView(R.id.item_detail_remark_remarkTextView);
    }

    @Override
    public void setData(DetailRemarkInfo data) {
        super.setData(data);

        if (data.isShowTitleTip) {
            titleTipView.setVisibility(View.VISIBLE);
            titleTextView.setTextColor(getContext().getResources().getColor(R.color.colorBlack));
        } else {
            titleTipView.setVisibility(View.GONE);
            titleTextView.setTextColor(getContext().getResources().getColor(R.color.colorTextPrimary));
        }

        if (TextUtils.isEmpty(data.topLeft) && TextUtils.isEmpty(data.topRight)) {
            topLinearLayout.setVisibility(View.GONE);
            topLineView.setVisibility(View.GONE);
        } else {
            topLinearLayout.setVisibility(View.VISIBLE);
            topLineView.setVisibility(View.VISIBLE);
        }

        if (!TextUtils.isEmpty(data.topLeft)){

            topLeftTextView.setText(Html.fromHtml(data.topLeft));
        }
        if (!TextUtils.isEmpty(data.topRight)){

            topRightTextView.setText(Html.fromHtml(data.topRight));
        }


        if (TextUtils.isEmpty(data.title)) {
            titleTextView.setVisibility(View.GONE);
        } else {
            titleTextView.setText(data.title);
            titleTextView.setVisibility(View.VISIBLE);
        }

        remarkTextView.setText(data.remark);
    }
}
